﻿using System.Security.Cryptography;
using System.Text;

namespace MSP.Business.Logic
{
    internal class Tools
    {
        public static string Encrypt(string salt)
        {
            Encoder enc = Encoding.Unicode.GetEncoder();

            var unicodeData = new byte[salt.Length * 2];
            enc.GetBytes(salt.ToCharArray(), 0, salt.Length, unicodeData, 0, true);

            SHA1 sha = new SHA1Managed();

            byte[] hashData = sha.ComputeHash(unicodeData);

            var sb = new StringBuilder();
            for (int i = 0; i < hashData.Length; i++)
            {
                sb.Append(hashData[i].ToString("x2"));
            }
            return sb.ToString();
        }


    }
}
